package com.demo.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import androidx.annotation.ColorInt;
import androidx.annotation.Nullable;
import androidx.annotation.StringRes;

import com.module.commonui.R;

public class DeviceCardInfoView extends LinearLayout {
    private ImageView ivFirst, ivSecond;
    private TextView tvFirst, tvSecond;
    private View view1, view2;
    private LinearLayout linearLayout;
    public TextView getTvFirst(){
        return tvFirst;
    }

    public TextView getTvSecond(){
        return tvSecond;
    }

    public ImageView getIvFirst(){
        return ivFirst;
    }

    public ImageView getIvSecond(){
        return ivSecond;
    }

    public View getView1(){
        return view1;
    }

    public View getView2(){
        return view2;
    }

    public LinearLayout getLinearLayout(){
        return linearLayout;
    }
    public DeviceCardInfoView(Context context) {
        super(context);
        initContentView(context);
    }

    public DeviceCardInfoView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public DeviceCardInfoView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initContentView(context);
    }

    public void initContentView(Context context) {
        View view = LayoutInflater.from(context).inflate(R.layout.device_home_service_info, this);
        ivFirst = view.findViewById(R.id.btn_device_function_first);
        tvFirst = view.findViewById(R.id.tv_device_function_first);
        ivSecond = view.findViewById(R.id.btn_device_function_second);
        tvSecond = view.findViewById(R.id.tv_device_function_second);
        view1 = view.findViewById(R.id.view1);
        view2 = view.findViewById(R.id.view2);
        linearLayout = view.findViewById(R.id.ll_device_card_services);
    }

    public void setSecondTextColor(@ColorInt int color){
        tvSecond.setTextColor(color);
    }

    public void setFirstTextColor(@ColorInt int color){
        tvFirst.setTextColor(color);
    }

    public void setTextColor(@ColorInt int color){
        tvFirst.setTextColor(color);
        tvSecond.setTextColor(color);
    }


    public void setFirstImageIcon(int icon){
        ivFirst.setImageResource(icon);
    }


    public void setSecondText(@StringRes int resId){
        tvSecond.setText(resId);
    }

    public void setSecondText(String text){
        tvSecond.setText(text);
    }

    public void setFirstText(@StringRes int resId){
        tvFirst.setText(resId);
    }

    public void setSecondImageIcon(int icon){
        ivSecond.setImageResource(icon);
    }

    public void showFirstControl(boolean show){
        ivFirst.setVisibility(show? VISIBLE : GONE);
        tvFirst.setVisibility(show? VISIBLE : GONE);
    }

    public void showSecondControl(boolean show){
        ivSecond.setVisibility(show? VISIBLE : GONE);
        tvSecond.setVisibility(show? VISIBLE : GONE);
    }

}